Some electronic devices, such as storage modules, have read-only memory (ROM) storing executable code. While executable code can instead be stored in non-volatile memory (e.g., Flash) and read into random-access memory (RAM) for execution, ROM is less expensive and has higher performance and lower power consumption than RAM. Because ROM is read-only, ROM is ideal for executable code that has been developed to maturity, where no changes are expected. However, in a quick-development-time environment where code is written quickly, changes to the executable code written in ROM may be needed if product requirements change and/or if bugs are found. In such situations and when the device is a system built of discrete components, the ROM chip may need to be removed from the device and replaced with a new ROM chip containing the modified code. This process may be impractical and expensive when the device is already deployed in the field. Further, if the device is an integrated circuit with integrated ROM, modifying the ROM can be an expensive and lengthy process that involves an additional tape-out.
To avoid ROM replacement, the executable code can be written so that any function that is subject to change can be called in an indirect way via function pointers stored in RAM. In this method, known as function vectoring, whenever a function needs to be modified, a replacement function is created and loaded to RAM, and the function pointers are changed to point to the replacement function instead of the original function in ROM. However, function vectoring can be very inefficient, as the full function needs to be replaced even if a single line in the function is changed. Also, because there is no a-priori knowledge of which functions may change in the future, function pointers are used for all the functions, which require a large amount of RAM.